precompile(secp256r1): align RIP-7212 with EIP-7951 specification#3012
Closed
doocho wants to merge 2 commits intobluealloy:mainfrom
Closed
precompile(secp256r1): align RIP-7212 with EIP-7951 specification#3012doocho wants to merge 2 commits intobluealloy:mainfrom
doocho wants to merge 2 commits intobluealloy:mainfrom
Conversation
…canonical bounds; modular comparison via verifier); keep Osaka gas at 6900
…oint, r/s bounds, qx/qy bounds, Osaka gas)
CodSpeed Performance ReportMerging #3012 will not alter performanceComparing Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Overview
This PR adds explicit infinity point validation to the secp256r1 precompile to comply with EIP-7951: Precompile for secp256r1 Curve Support specification.
Key Change
Added Infinity Point Check
This prevents consensus failures from infinity point attacks by explicitly rejecting the point-at-infinity encoding.
EIP-7951 Compliance
The implementation satisfies EIP-7951 requirements through:
1. Precompile Address
0x100(256) -P256VERIFY_ADDRESS = 2562. Gas Costs
P256VERIFY_BASE_GAS_FEE_OSAKA)3. Input Validation (via p256 library)
0 < r < n, 0 < s < n(enforced bySignature::from_slice)0 ≤ qx < p, 0 ≤ qy < p(enforced byVerifyingKey::from_encoded_point)qy² ≡ qx³ + ax + b (mod p)(enforced byVerifyingKey::from_encoded_point)input.len() != 160)4. Modular Comparison
r' ≡ r (mod n)(handled by p256 library'sverify_prehash)5. Failure Handling
Testing
Added Test Cases
r = 0ands = 0rejectionr ≥ nands ≥ nrejectionqx ≥ pandqy ≥ prejectionCompatibility
References